package com.chen.corejava.collection;

import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;

import com.chen.corejava.Student;

/**
 *弱散列映射表
 *@author：email: <a href="cyb@ewppay.com"> Administrator </a> 
 *@Date 2017-2-17 下午6:51:56 
 */

public class WeakHashMapTest {
	/**
	 * @param @param args   
	 * @return void  
	 * @throws
	 * @author cyb
	 * @date 2017-2-17
	 */
	public static void main(String[] args) {
		
		WeakHashMap wMap = new WeakHashMap();
		Student p1 = new Student("张三",20);
		Student p2 = new Student("李四",30);
		wMap.put(p1, "zs");
		wMap.put(p2, "ls");
		p1=null;
		//gc
		try {
		System.gc();
		Thread.sleep(1000);
		} catch (InterruptedException e) {
		e.printStackTrace();
		}

		for (Object o : wMap.entrySet()) {
		System.out.println(o);
		}
	}

}
